package org.d11_object_stream;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * 目标：掌握对象字节输出流的使用：序列化对象
 */
public class TestObjectOutPutStream {
    public static void main(String[] args) {
        try (

              //2.创建一个对象字节输出流包装原始的字节输出流
              ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("D:\\idea\\idea code\\java-practice\\practice\\change\\file-oi-app\\src\\test\\d11test.txt"))
        ){
            //1.创建Java对象
            User u = new User("admin","张三",34,"555547");
            oos.writeObject(u);
            System.out.println("序列化对象成功");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
